﻿<?php
require_once "config.php";
require_once "dbconfig.php";
$tab = "share";
require_once "tab.inc.php";
if($_POST['method'] == "insert"){
	$outId = $_POST['outId'];
	$dietPlanMorning = $_POST['dietPlanMorning'];
	$dietPlanNoon = $_POST['dietPlanNoon'];
	$dietPlanNight = $_POST['dietPlanNight'];
	$sportsPlan = $_POST['sportsPlan'];
	$status = $_POST['status'];
	$memo = $_POST['memo'];
	$title = $_POST['title'];
	$userName = $_POST['userName'];
	$sex = $_POST['sex'];
	$sqlInsert = "insert into app_pp_share_health(out_id,user_name,status,title,diet_plan_morning,diet_plan_noon,diet_plan_night,sports_plan,memo,sex) values(".$outId.",'".$userName."',".$status.",'".$title."','".$dietPlanMorning."','".$dietPlanNoon."','".$dietPlanNight."','".$sportsPlan."','".$memo."','".$sex."')";
	$flag = mysql_db_query($database, $sqlInsert);
	require_once('xiaonei.class.php');
	$xn = new XNapp($apiKey,$secret);
	$params = array (
			"template_id"		=> 3,
			"title_data"		=> '{"actor":'.$userName.'}', //这个参数的传入必须是json格式
			"body_data"			=> '{"appName":"<a href='.$_ENV['xiaoneiUrl'].'>你比我胖</a>","url":"<a href='.$_ENV['xiaoneiUrl'].'share.php>去看看</a>"}' //这个参数的传入必须是json格式
	);
	$xn->feed('publishTemplatizedAction',$params);
}
$sqlQuery = "select * from app_pp_share_health where status='1' order by gmt_create desc";
$result = mysql_db_query($database, $sqlQuery);
?>

<div>
	<div style="font-size:13px; font-weight:bold; border-bottom:1px solid #EBEFF4; height:30px;">
		<div style="width:100px;float:right"><img src="http://movie.img.xiaonei.com/abc//img/vote_s.gif" >&nbsp;<a href="addshare.php"><span style="color:red">我要分享</span></a></div>
		
	</div>
<?php
while($row = mysql_fetch_object($result)){
?>
<ul style="background:#FFF6FB;height:auto;padding:10px;margin-bottom:10px;">
            <h2 style="font-size:12px;height:10px;">
				<span style="float:left;"><a href="<?php echo $_ENV['webUrl']."/shareDetail.php?shareId=".$row->share_id."&outId=".$uid."&userName=".$row->user_name;?>" target="_blank" ><?php if($row->title !=""){ echo $row->title ;}else{ echo $row->user_name."的瘦身分享";}?></a></span>
				<span style="float:right;font-size:12px;font-weight:lighter;">发布者:<a href="http://xiaonei.com/getuser.do?id=<?php echo $row->out_id ?>" target="_blank" ><?php echo $row->user_name;?>(<?php echo $row->sex==1?"男":"女";?>)</a></span>
			</h2>
            <li>&nbsp;&nbsp;&nbsp;&nbsp;<b>饮食计划</b>：<?php echo "早餐:".$row->diet_plan_morning;?>....</li>
            <li>&nbsp;&nbsp;&nbsp;&nbsp;<b>运动计划</b>：<?php echo "早晨:".$row->sports_plan;?>....</li>
 </ul>
<?php } ?>
</div>
<?php
	mysql_close();
?>	



